<%--
  Created by IntelliJ IDEA.
  User: Kevin
  Date: 2021/6/2
  Time: 10:31
  To change this template use File | Settings | File Templates.
--%>
<%@page import="cn.kgc.pojo.*" %>
<%@page import="java.util.List" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page isELIgnored="false" %>

<html>
<head>
    <title>Title</title>
</head>
<body>
<div>
    <p>请选择商品分类
    <form method="post" action="all">
        <select name="sortId">
            <option name="did" value="0">不限</option>
            <c:forEach items="${districts}" var="d">
                <option
                        <c:if test="${d.id==did}">selected="selected"</c:if>
                        value="${d.id}">${d.name}</option>
            </c:forEach>
        </select>
        <input type="submit" value="查找"/>
    </form>
    </p>
    <table>
        <tr>
            <td>商品编号</td>
            <td>商品名称</td>
            <td>商品分类</td>
            <td>产地</td>
            <td>生产日期</td>
            <td>单价（元）</td>
            <td>剩余数量</td>
            <td>购买</td>
        </tr>
        <c:forEach var="detail" items="${pageInfo.list}">
            <tr>
                <td>${detail.id}</td>
                <td>${detail.name}</td>
                <td>${detail.sortName}</td>
                <td>${detail.address}</td>
                <td>${detail.createDate}</td>
                <td>${detail.price}</td>
                <td>${detail.reamaining}</td>
                <td><a href="buy?id=${detail.id}">购买</a></td>
            </tr>
        </c:forEach>
    </table>
    <p>
        当前是第${pageInfo.pageNum}/${pageInfo.pages}页 共${pageInfo.total}条数据
        <a href="${pageContext.request.contextPath}/all?pageIndex=1">首页</a>
        <c:if test="${pageInfo.pageNum>1}"><a
                href="${pageContext.request.contextPath}/all?pageIndex=${pageInfo.pageNum-1}&did=${did}">上一页</a></c:if>
        <c:if test="${pageInfo.pageNum<=pageInfo.pages&&pageInfo.pageNum!=0}"><a
                href="${pageContext.request.contextPath}/all?pageIndex=${pageInfo.pageNum+1}&did=${did}">下一页</a></c:if>
        <a href="${pageContext.request.contextPath}/all?pageIndex=${pageInfo.pages}&did=${did}">末页</a>
    </p>
</div>
</body>
</html>